let version = Number(localStorage.getItem("version")) || 1;
 // getItem返回的是string类型需要转化
let notifyList = new Array();
export function setVersion(newVersion: number) {
	version = newVersion;
	localStorage.setItem("version", String(newVersion));
    for(var notify of notifyList){
        notify.func(newVersion);
        console.log("[version.js] 执行监听事件", notify.name);
    } 
}
export function getVersion() {
    return version;
}
export function addListener(name: string, thing: Function) {
    console.log("[version.js] 添加监听器", name);
    notifyList.push({name:name, func: thing});
}
export function addImportListener(name: string, thing: Function){
    console.log("[version.js] 添加重要监听器", name);
    notifyList.unshift({name:name, func: thing});
}
export function removeListener(name: string) {
    console.log("[version.js] 删除监听器", name);
    notifyList = notifyList.filter((notify)=> notify.name != name);
}